﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


class MostFrequentNumberInArray
{
    static void SeqOfEqualElements(int[] arr)
    {
        int value = int.MinValue;
        int count = 1;
        int maxCount = 1;
        for (int i = 0; i < arr.Length - 1; i++)
        {
            if (arr[i] == arr[i + 1])
            {
                count++;
                if (count > maxCount)
                {
                    maxCount = count;
                    value = arr[i];
                }
            }

            else
            {
                count = 1;
            }
        }

        //for (int i = 0; i < maxCount - 1; i++)
        //{
        //    Console.Write(value + ", ");
        //}
        //Console.WriteLine(value);
        Console.WriteLine(value.ToString() + " " +"(" + maxCount.ToString() + " times" + ")");
    }

    static void Main()
    {
        int[] arr = { 4, 1, 2, 2, 3, 4, 8, 1, 2, 5, 4, 2, 2, 6 };
        Array.Sort(arr);
        SeqOfEqualElements(arr);
    }
}

